package com.zp.self.module.eventBus.controller;

import com.zp.self.module.eventBus.bean.MessageEvent;
import com.zp.self.module.eventBus.service.MessagePublisherServiceImpl;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author By ZengPeng
 */
@RestController
public class EventBusSendController {
    @Resource
    MessagePublisherServiceImpl messagePublisher;

    /**
     * 测试同步发送事件
     */
    @PostMapping(value = "/eventBusSend")
    public Object sendMessage(@RequestBody MessageEvent messageEvent) {
        messagePublisher.sendMessage(messageEvent);
        return "200";
    }


    /**
     * 测试异步发送事件
     */
    @PostMapping(value = "/asyncSendMessage")
    public Object asyncSendMessage(@RequestBody MessageEvent messageEvent) {
        messagePublisher.asyncSendMessage(messageEvent);
        return "200";
    }
}
